<template>
  <el-menu :default-openeds="opens" style="height: 100%; overflow: hidden"
           background-color="rgb(48, 65, 86)"
           text-color="#fff"
           active-text-color="#448ada"
           :collapse-transition="false"
           :collapse="isCollapse"
           router
  >

    <div style="height: 60px; line-height: 60px; text-align: center">
      <img src="../assets/logo.png" alt="" style="width: 20px; position: relative; top: 5px;">
      <b style="color: white; margin-left: 5px" v-show="logoTextShow">信用数据归集系统</b>
    </div>
    <div v-for="item in menus" :key="item.id">
      <div v-if="item.path">
        <el-menu-item :index="item.path">
          <i :class="item.icon"></i>
          <span slot="title">{{ item.name }}</span>
        </el-menu-item>
      </div>
      <div v-else>
        <el-submenu :index="item.id + ''">
          <template slot="title">
            <i :class="item.icon"></i>
            <span slot="title">{{ item.name }}</span>
          </template>
          <div  v-for="subItem in item.children" :key="subItem.id">
            <el-menu-item :index="subItem.path">
              <i :class="subItem.icon"></i>
              <span slot="title">{{ subItem.name }}</span>
            </el-menu-item>
          </div>
        </el-submenu>
      </div>
    </div>

<!--    <div style="height: 60px; line-height: 60px; text-align: center">-->
<!--      <img src="../assets/logo.png" alt="" style="width: 20px; position: relative; top: 5px; margin-right: 5px">-->
<!--      <b style="color: white" v-show="logoTextShow">信用数据归集系统</b>-->
<!--    </div>-->
<!--    <el-submenu index="1">-->
<!--      <template slot="title">-->
<!--        <i class="el-icon-pie-chart"></i>-->
<!--        <span slot="title">信用评价</span>-->
<!--      </template>-->
<!--      <el-menu-item-group>-->
<!--        <el-menu-item index="/echarts1">总体概况</el-menu-item>-->
<!--        <el-menu-item index="1-2">历年情况</el-menu-item>-->
<!--      </el-menu-item-group>-->
<!--    </el-submenu>-->
<!--    <el-submenu index="2">-->
<!--      <template slot="title">-->
<!--        <i class="el-icon-menu"></i>-->
<!--        <span slot="title">商家信息</span>-->
<!--      </template>-->
<!--      <el-menu-item-group>-->
<!--        <el-menu-item index="/basic">基础信息</el-menu-item>-->
<!--        <el-menu-item index="/license">行政许可信息</el-menu-item>-->
<!--      </el-menu-item-group>-->
<!--    </el-submenu>-->
<!--    <el-submenu index="3">-->
<!--      <template slot="title">-->
<!--        <i class="el-icon-folder"></i>-->
<!--        <span slot="title">信用档案</span>-->
<!--      </template>-->
<!--      <el-menu-item-group>-->
<!--        <el-menu-item index="/penalty">行政处罚信息</el-menu-item>-->
<!--        <el-menu-item index="/abnormal">经营异常单位</el-menu-item>-->
<!--        <el-menu-item index="/serious">严重失信单位</el-menu-item>-->
<!--      </el-menu-item-group>-->
<!--    </el-submenu>-->
<!--    <el-submenu index="4">-->
<!--      <template slot="title">-->
<!--        <i class="el-icon-setting"></i>-->
<!--        <span slot="title">评价标准</span>-->
<!--      </template>-->
<!--      <el-menu-item-group>-->
<!--        <el-menu-item index="/file">文件下载</el-menu-item>-->
<!--      </el-menu-item-group>-->
<!--    </el-submenu>-->
<!--    <el-submenu index="5">-->
<!--      <template slot="title">-->
<!--        <i class="el-icon-user"></i>-->
<!--        <span slot="title">部门管理</span>-->
<!--      </template>-->
<!--      <el-menu-item-group>-->
<!--        <el-menu-item index="/people">人员信息</el-menu-item>-->
<!--      </el-menu-item-group>-->
<!--      <el-menu-item-group>-->
<!--        <el-menu-item index="/menu">菜单功能</el-menu-item>-->
<!--      </el-menu-item-group>-->
<!--      <el-menu-item-group>-->
<!--        <el-menu-item index="/role">权限管理</el-menu-item>-->
<!--      </el-menu-item-group>-->
<!--    </el-submenu>-->
  </el-menu>
</template>

<script>
export default {
  name: "Aside",
  props: {
    isCollapse: Boolean,
    logoTextShow: Boolean,
  },
  data() {
    return {
      menus: localStorage.getItem("menus") ? JSON.parse(localStorage.getItem("menus")) : [],
      opens: localStorage.getItem("menus") ? JSON.parse(localStorage.getItem("menus")).map(v => v.id + '') : []
    }
  },

}
</script>

<style scoped>
.el-menu-item.is-active {
  background-color: rgb(38, 52, 69) !important;
}
.el-menu-item:hover {
  background-color: rgb(38, 52, 69) !important;
}

.el-submenu__title:hover {
  background-color: rgb(38, 52, 69) !important;
}
/*解决收缩菜单文字不消失问题*/
.el-menu--collapse span {
  visibility: hidden;
}
</style>